1. Technical Field
This invention generally relates to object oriented programming and more specifically relates to an apparatus and method for recycling objects in an object oriented system.
2. Background Art
The development of the EDVAC computer system of 1948 is often cited as the beginning of the computer era. Since that time, computer systems have evolved into extremely sophisticated devices, and computer systems may be found in many different settings. Computer systems typically include a combination of hardware, such as semiconductors and circuit boards, and software, also known as computer programs. As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
Computer systems typically include operating system software that controls the basic function of the computer, and one or more software application programs that run under the control of the operating system to perform desired tasks. For example, a typical IBM Personal Computer may run the OS/2 operating system, and under the control of the OS/2 operating system, a user may execute an application program, such as a word processor. As the capabilities of computer systems have increased, the application software programs designed for high performance computer systems have become extremely powerful. Additionally, software development costs have continued to rise because more powerful and complex programs take more time, and hence more money, to produce.
One way in which the performance of application software programs has been improved while the associated development costs have been reduced is by using object oriented programming concepts. The goal of using object oriented programming is to create small, reusable sections of program code known as "objects" that can be quickly and easily combined and re-used to create new programs. This is similar to the idea of using the same set of building blocks again and again to create many different structures. The modular and re-usable aspects of objects will typically speed development of new programs, thereby reducing the costs associated with the development cycle. In addition, by creating and re-using a comprehensive set of well-tested objects, a more stable, uniform, and consistent approach to developing new computer programs can be achieved.
A central concept in object oriented programming is the "class." A class is a template that defines a type of object. A class outlines or describes the characteristics or makeup of objects that belong to that class. By defining a class, objects can be created that belong to the class without having to rewrite the entire definition for each new object. This feature of object oriented programming promotes the reusability of existing object definitions and promotes more efficient use of program code.
Modern object oriented programming languages have features that improve the convenience of programming in those languages. For example, the Java programming language developed by Sun Microsystems has a garbage collection feature that automatically disposes of objects that are no longer used. This automatic garbage collection takes away from the programmer the burden of tracking which objects are used and which are not, and disposing of objects that are no longer used.
In some situations, it may be desirable to recycle an object rather than dispose of it. In most object oriented systems, a control mechanism is used to create and delete objects. When a new object needs to be created, a request is made to the control mechanism, which allocates memory for the new object and returns a pointer to the new object. However, if there exists an old object that is an instance of the same class as the new object, it may be possible to recycle the old object by initializing the data in the object and returning a pointer to the object. If an unused object can be recycled in this manner, the time-consuming process of allocating memory and creating a new object can be avoided, which enhances system performance. In addition, recycling of objects reduces garbage collection time. Another benefit of recycling is that it helps reduce memory fragmentation by reusing an existing object that has the perfect size of memory already allocated to it. When memory becomes severely fragmented, the control mechanism takes a longer period of time to allocate memory to a new object. As can be seen from the many benefits discussed above, recycling of objects provides an enhancement to overall system performance.
Recycling an object in an object oriented system that has automatic garbage collection, such as a Java virtual machine, poses certain problems. The garbage collection mechanism typically makes no determination regarding whether or not an object can be recycled. Instead, the garbage collection mechanism automatically disposes of an object when the object is no longer referenced, thus deleting an object that may possibly be recycled if allowed to remain. Without a mechanism for recycling objects while allowing for automatic garbage collection of objects, the computer industry will continue to suffer from object oriented computer systems that do not fully take advantage of their potential performance.